<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>        

<script type="text/javascript">	
	$(document).ready(function(){
		//초기에 화면에 뿌려줄 내용
		$.ajax({
			type:"POST",
			url:"hopeSubjectList.do",
			dataType:"json",
			success:function(jsonData){	
 				//학교학년 가져와서 뿌리기
				$("#grade_grade option").remove();
				var op="<option value=''>--</option>";
				$("#grade_grade").append(op);
 				$.each(jsonData.gradeList,function(index, gradelist){
 					op="<option value="+gradelist.code_code+">"+gradelist.code_name+"</option>";
					$("#grade_grade").append(op); 					
				});
			}//success
		});//ajax
		
		$("#searchBtn").click(function(){
			var grade_name=$("#grade_name").val();
			var grade_grade=$("#grade_grade").val();
			if(grade_grade=="" && grade_name==""){
				alert("검색조건을 입력하세요.");
			//	return false;
			}else{	//조건에 따른 검색
				alert("이름 : "+grade_name+"학교 : "+grade_grade+"검색조건으로 검색하시겠습니까?.");
				$.ajax({
					type:"post",
					url:"getSearchStudentbyGrade.do",
					data:"grade_name="+grade_name+"&grade_grade="+grade_grade,  //	data:$("#tradeForm").serialize(),
					dataType:"json",
					success:function(jsonData){
						alert("검색조건 성공!!");
					}
				});			//ajax	
			}	//if
		});	//click

		$("a[id=studentName]").click(function(){
			alert($(this).next().val());
		});
	});
</script>
<form id=searchForm >
<table >
	<tr>
		<td>학년</td><td><select id="grade_grade" name="grade_grade"></select></td>
		<td>이름</td><td><input type="text" id="grade_name" name="grade_name"></td>
		<td align="right"><input type="button" id="searchBtn" value="검색"> </td>		
	</tr>
</table>
</form>
<table width="560" cellpadding="2" cellspacing="0"><tr align="right"><td>
총 학생 수 : ${requestScope.listVO.pagingBean.totalContent}
</td></tr></table>	
<table width="560"  border="1" cellpadding="2" cellspacing="0">
	<thead>
		<tr><td width="20%">이름</td>
			 <td width="20%">성별</td>
			 <td width="20%">희망지역</td>
			 <td width="20%">희망과목</td>
			 <td width="20%">학교</td>
		</tr>
	</thead>
	<tbody>
			<c:forEach var="mvo" items="${requestScope.listVO.list}" >		
			<tr>
			    <td><a href="#" id="studentName">${mvo.name }</a>
			    <input type="hidden" id="hidden_mvo" value="${mvo }">
			    		<span id="studentInfo" ></span></td>			
				<td>${mvo.gender}</td>
				<td>${mvo.hoperegion}</td>
				<td>${mvo.hopesubject}</td>
				<td><input type="text" id="grade_id" value="${mvo.id }"></td>
			</tr>
			</c:forEach>	
	</tbody>
</table><br>
<table width="560"  cellpadding="2" cellspacing="0"><tr align="center"><td>
<c:set var="pb" value="${requestScope.listVO.pagingBean}"></c:set>
<c:if test="${pb.previousPageGroup}">
	<a href="tabGradeView.do?pageNo=${pb.startPageOfPageGroup-1 }">	Pre </a>
</c:if>	

<c:forEach var="pageNo" begin="${pb.startPageOfPageGroup }" 
										end="${pb.endPageOfPageGroup }">
<c:choose>
<c:when test="${pb.nowPage !=pageNo }" >
	<a href="tabGradeView.do?pageNo=${pageNo }" >${pageNo }</a>
</c:when>
<c:otherwise>
	${pageNo} 
</c:otherwise>
</c:choose>
</c:forEach>

<c:if test="${pb.nextPageGroup}">
	<a href="tabGradeView.do?pageNo=${pb.endPageOfPageGroup+1 }">Next </a>
</c:if>
</td></tr></table>